package com.jeesite.modules.billnopattern.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

/**
 * 单据编码记录表Entity
 * @author 码脑洞
 * @version 2025-04-13
 */
@Table(name="t_bill_no_pattern", alias="a", label="单据编码记录表信息", columns={
		@Column(name="auto_id", attrName="autoId", label="主键", isPK=true),
		@Column(name="org_id", attrName="orgId", label="组织ID"),
		@Column(name="org_code", attrName="orgCode", label="组织编码"),
		@Column(name="org_name", attrName="orgName", label="组织名称", queryType=QueryType.LIKE),
		@Column(name="type", attrName="type", label="单号类型", comment="单号类型：1. 表单 2. 条码号"),
		@Column(name="source_id", attrName="sourceId", label="来源ID;表单ID或条码类型ID"),
		@Column(name="pattern", attrName="pattern", label="单号格式"),
		@Column(name="serial_length", attrName="serialLength", label="流水号位数"),
		@Column(name="init_seq", attrName="initSeq", label="起始序号"),
		@Column(name="seq", attrName="seq", label="当前序号值"),
		@Column(name="version_num", attrName="versionNum", label="乐观锁标识"),
	}, orderBy="a.auto_id DESC"
)
public class BillNoPattern extends DataEntity<BillNoPattern> {
	
	private static final long serialVersionUID = 1L;
	private Long autoId;		// 主键
	private Long orgId;		// 组织ID
	private String orgCode;		// 组织编码
	private String orgName;		// 组织名称
	private String type;		// 单号类型：1. 表单 2. 条码号
	private Long sourceId;		// 来源ID;表单ID或条码类型ID
	private String pattern;		// 单号格式
	private Integer serialLength;		// 流水号位数
	private Integer initSeq;		// 起始序号
	private Integer seq;		// 当前序号值
	private Long versionNum;		// 乐观锁标识

	public BillNoPattern() {
		this(null);
	}
	
	public BillNoPattern(String id){
		super(id);
	}
	
	@JsonSerialize(using = ToStringSerializer.class)
	public Long getAutoId() {
		return autoId;
	}

	public void setAutoId(Long autoId) {
		this.autoId = autoId;
	}
	
	@NotNull(message="组织ID不能为空")
	public Long getOrgId() {
		return orgId;
	}

	public void setOrgId(Long orgId) {
		this.orgId = orgId;
	}
	
	@NotBlank(message="组织编码不能为空")
	@Size(min=0, max=10, message="组织编码长度不能超过 10 个字符")
	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}
	
	@NotBlank(message="组织名称不能为空")
	@Size(min=0, max=30, message="组织名称长度不能超过 30 个字符")
	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}
	
	@NotBlank(message="单号类型不能为空")
	@Size(min=0, max=1, message="单号类型长度不能超过 1 个字符")
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	@NotNull(message="来源ID;表单ID或条码类型ID不能为空")
	public Long getSourceId() {
		return sourceId;
	}

	public void setSourceId(Long sourceId) {
		this.sourceId = sourceId;
	}
	
	@NotBlank(message="单号格式不能为空")
	@Size(min=0, max=60, message="单号格式长度不能超过 60 个字符")
	public String getPattern() {
		return pattern;
	}

	public void setPattern(String pattern) {
		this.pattern = pattern;
	}
	
	@NotNull(message="流水号位数不能为空")
	public Integer getSerialLength() {
		return serialLength;
	}

	public void setSerialLength(Integer serialLength) {
		this.serialLength = serialLength;
	}
	
	@NotNull(message="起始序号不能为空")
	public Integer getInitSeq() {
		return initSeq;
	}

	public void setInitSeq(Integer initSeq) {
		this.initSeq = initSeq;
	}
	
	@NotNull(message="当前序号值不能为空")
	public Integer getSeq() {
		return seq;
	}

	public void setSeq(Integer seq) {
		this.seq = seq;
	}
	
	@NotNull(message="乐观锁标识不能为空")
	public Long getVersionNum() {
		return versionNum;
	}

	public void setVersionNum(Long versionNum) {
		this.versionNum = versionNum;
	}
	
}